package map;

import map.graph.MapGraph;

import com.taxi.server.carsearch.graph.Way;
import com.taxi.server.carsearch.mathutils.Line;
import com.taxi.server.carsearch.mathutils.MathAnalyzer;

public class MapGraphAnalyzer {

	public static Way getClosestWay(Line gpsline, MapGraph graph) {
		double minmeasure = 1. / 0; // infinity
		Way minWay = null;
		for (Way w : graph.getWays()) {
			double measure = MathAnalyzer.calcMeasureOfProximity(w.getLine(),
					gpsline);
			if (measure < minmeasure) {
				minmeasure = measure;
				minWay = w;
			}
		}
		return minWay;
	}

}
